using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using myGA;
using myGA.Functions;

namespace myGATool
{
	// delegate to keep up with dynamic selection of function from form
	//public delegate double AFunction(double[] values);

	public class GATool : System.Windows.Forms.Form
	{
		#region Windows Form Designer generated code

		public GATool()
		{
			InitializeComponent();
		}
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.TextBox textBox2;
		private System.Windows.Forms.TextBox textBox3;
		private System.Windows.Forms.Button startButton;
		private System.Windows.Forms.Button quitButton;
		private System.Windows.Forms.Button stepButton;
		private System.Windows.Forms.TabControl tabControl1;
		private System.Windows.Forms.TabPage tabPage1;
		private System.Windows.Forms.TabPage tabPage2;
		private System.Windows.Forms.TabPage tabPage3;
		private System.Windows.Forms.RichTextBox output1TextBox;
		private System.Windows.Forms.TextBox textBox4;
		private System.Windows.Forms.TextBox textBox5;
		private System.Windows.Forms.TextBox textBox6;
		private System.Windows.Forms.TabPage tabPage5;
		private System.Windows.Forms.RichTextBox output2TextBox;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.NumericUpDown functionResUpDown;
		private System.Windows.Forms.TextBox textBox7;
		private System.Windows.Forms.TextBox textBox8;
		private System.Windows.Forms.TextBox textBox9;
		private System.Windows.Forms.TextBox textBox10;
		private System.Windows.Forms.TextBox textBox11;
		private System.Windows.Forms.TextBox textBox12;
		private System.Windows.Forms.TabPage tabPage6;
		private System.Windows.Forms.TabControl tabControl2;
		private System.Windows.Forms.TabPage tabPage7;
		private System.Windows.Forms.TabPage tabPage8;
		private System.Windows.Forms.TabPage tabPage9;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.NumericUpDown periodUpDown;
		private System.Windows.Forms.NumericUpDown polyCUpDown;
		private System.Windows.Forms.NumericUpDown polyBUpDown;
		private System.Windows.Forms.NumericUpDown polyAUpDown;
		private System.Windows.Forms.RadioButton xSquaredRadioButton;
		private System.Windows.Forms.RadioButton xCubedRadioButton;
		private System.Windows.Forms.Button evolveButton;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.TabPage tabPage4;
		private System.Windows.Forms.Label label10;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.NumericUpDown popSizeUpDown;
		private System.Windows.Forms.NumericUpDown selRateUpDown;
		private System.Windows.Forms.NumericUpDown muRateUpDown;
		private System.Windows.Forms.TabControl tabControl3;
		private System.Windows.Forms.TabPage tabPage10;
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.TabPage tabPage11;
		private System.Windows.Forms.TabPage tabPage12;
		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.Panel panel3;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.Label label12;
		private System.Windows.Forms.Label label13;
		private System.Windows.Forms.RadioButton polynomialRadioButton;
		private System.Windows.Forms.NumericUpDown maxGenUpDown;
		private System.Windows.Forms.RadioButton oneOverOneMinusXRadioButton;
		private System.Windows.Forms.RadioButton oneOverXRadioButton;
		private System.Windows.Forms.RadioButton logisticRadioButton;
		private System.Windows.Forms.RadioButton sigmoidRadioButton;
		private System.Windows.Forms.RadioButton sineExpRadioButton;
		private System.Windows.Forms.RadioButton absSineRadioButton;
		private System.Windows.Forms.RadioButton SineRadioButton;
		private System.Windows.Forms.RadioButton expSineRadioButton;
		private System.Windows.Forms.RadioButton xSineRadioButton;
		private System.ComponentModel.IContainer components;

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		private void InitializeComponent()
		{
            this.startButton = new System.Windows.Forms.Button();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.textBox2 = new System.Windows.Forms.TextBox();
            this.textBox3 = new System.Windows.Forms.TextBox();
            this.quitButton = new System.Windows.Forms.Button();
            this.output1TextBox = new System.Windows.Forms.RichTextBox();
            this.stepButton = new System.Windows.Forms.Button();
            this.tabControl1 = new System.Windows.Forms.TabControl();
            this.tabPage4 = new System.Windows.Forms.TabPage();
            this.label10 = new System.Windows.Forms.Label();
            this.maxGenUpDown = new System.Windows.Forms.NumericUpDown();
            this.label3 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.popSizeUpDown = new System.Windows.Forms.NumericUpDown();
            this.selRateUpDown = new System.Windows.Forms.NumericUpDown();
            this.muRateUpDown = new System.Windows.Forms.NumericUpDown();
            this.tabPage6 = new System.Windows.Forms.TabPage();
            this.tabControl2 = new System.Windows.Forms.TabControl();
            this.tabPage9 = new System.Windows.Forms.TabPage();
            this.label13 = new System.Windows.Forms.Label();
            this.label12 = new System.Windows.Forms.Label();
            this.label11 = new System.Windows.Forms.Label();
            this.polyCUpDown = new System.Windows.Forms.NumericUpDown();
            this.polyBUpDown = new System.Windows.Forms.NumericUpDown();
            this.polyAUpDown = new System.Windows.Forms.NumericUpDown();
            this.polynomialRadioButton = new System.Windows.Forms.RadioButton();
            this.xSquaredRadioButton = new System.Windows.Forms.RadioButton();
            this.xCubedRadioButton = new System.Windows.Forms.RadioButton();
            this.tabPage8 = new System.Windows.Forms.TabPage();
            this.sigmoidRadioButton = new System.Windows.Forms.RadioButton();
            this.logisticRadioButton = new System.Windows.Forms.RadioButton();
            this.oneOverXRadioButton = new System.Windows.Forms.RadioButton();
            this.oneOverOneMinusXRadioButton = new System.Windows.Forms.RadioButton();
            this.tabPage7 = new System.Windows.Forms.TabPage();
            this.xSineRadioButton = new System.Windows.Forms.RadioButton();
            this.sineExpRadioButton = new System.Windows.Forms.RadioButton();
            this.absSineRadioButton = new System.Windows.Forms.RadioButton();
            this.SineRadioButton = new System.Windows.Forms.RadioButton();
            this.expSineRadioButton = new System.Windows.Forms.RadioButton();
            this.label9 = new System.Windows.Forms.Label();
            this.periodUpDown = new System.Windows.Forms.NumericUpDown();
            this.tabPage1 = new System.Windows.Forms.TabPage();
            this.tabPage2 = new System.Windows.Forms.TabPage();
            this.output2TextBox = new System.Windows.Forms.RichTextBox();
            this.tabPage3 = new System.Windows.Forms.TabPage();
            this.textBox7 = new System.Windows.Forms.TextBox();
            this.textBox8 = new System.Windows.Forms.TextBox();
            this.textBox9 = new System.Windows.Forms.TextBox();
            this.textBox10 = new System.Windows.Forms.TextBox();
            this.textBox11 = new System.Windows.Forms.TextBox();
            this.textBox12 = new System.Windows.Forms.TextBox();
            this.textBox4 = new System.Windows.Forms.TextBox();
            this.textBox5 = new System.Windows.Forms.TextBox();
            this.textBox6 = new System.Windows.Forms.TextBox();
            this.tabPage5 = new System.Windows.Forms.TabPage();
            this.label4 = new System.Windows.Forms.Label();
            this.functionResUpDown = new System.Windows.Forms.NumericUpDown();
            this.evolveButton = new System.Windows.Forms.Button();
            this.button1 = new System.Windows.Forms.Button();
            this.tabControl3 = new System.Windows.Forms.TabControl();
            this.tabPage10 = new System.Windows.Forms.TabPage();
            this.panel1 = new System.Windows.Forms.Panel();
            this.tabPage11 = new System.Windows.Forms.TabPage();
            this.panel2 = new System.Windows.Forms.Panel();
            this.tabPage12 = new System.Windows.Forms.TabPage();
            this.panel3 = new System.Windows.Forms.Panel();
            this.tabControl1.SuspendLayout();
            this.tabPage4.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.maxGenUpDown)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.popSizeUpDown)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.selRateUpDown)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.muRateUpDown)).BeginInit();
            this.tabPage6.SuspendLayout();
            this.tabControl2.SuspendLayout();
            this.tabPage9.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.polyCUpDown)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.polyBUpDown)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.polyAUpDown)).BeginInit();
            this.tabPage8.SuspendLayout();
            this.tabPage7.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.periodUpDown)).BeginInit();
            this.tabPage1.SuspendLayout();
            this.tabPage2.SuspendLayout();
            this.tabPage3.SuspendLayout();
            this.tabPage5.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.functionResUpDown)).BeginInit();
            this.tabControl3.SuspendLayout();
            this.tabPage10.SuspendLayout();
            this.tabPage11.SuspendLayout();
            this.tabPage12.SuspendLayout();
            this.SuspendLayout();
            // 
            // startButton
            // 
            this.startButton.Location = new System.Drawing.Point(472, 16);
            this.startButton.Name = "startButton";
            this.startButton.Size = new System.Drawing.Size(64, 24);
            this.startButton.TabIndex = 1;
            this.startButton.Text = "Start";
            this.startButton.Click += new System.EventHandler(this.startButton_Click);
            // 
            // textBox1
            // 
            this.textBox1.Location = new System.Drawing.Point(80, 32);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(56, 20);
            this.textBox1.TabIndex = 2;
            // 
            // textBox2
            // 
            this.textBox2.Location = new System.Drawing.Point(80, 64);
            this.textBox2.Name = "textBox2";
            this.textBox2.Size = new System.Drawing.Size(56, 20);
            this.textBox2.TabIndex = 3;
            // 
            // textBox3
            // 
            this.textBox3.Location = new System.Drawing.Point(80, 96);
            this.textBox3.Name = "textBox3";
            this.textBox3.Size = new System.Drawing.Size(56, 20);
            this.textBox3.TabIndex = 4;
            // 
            // quitButton
            // 
            this.quitButton.Location = new System.Drawing.Point(576, 48);
            this.quitButton.Name = "quitButton";
            this.quitButton.Size = new System.Drawing.Size(64, 24);
            this.quitButton.TabIndex = 11;
            this.quitButton.Text = "Quit";
            this.quitButton.Click += new System.EventHandler(this.quitButton_Click);
            // 
            // output1TextBox
            // 
            this.output1TextBox.Location = new System.Drawing.Point(8, 8);
            this.output1TextBox.Name = "output1TextBox";
            this.output1TextBox.Size = new System.Drawing.Size(384, 328);
            this.output1TextBox.TabIndex = 12;
            this.output1TextBox.Text = "";
            // 
            // stepButton
            // 
            this.stepButton.Location = new System.Drawing.Point(544, 16);
            this.stepButton.Name = "stepButton";
            this.stepButton.Size = new System.Drawing.Size(64, 24);
            this.stepButton.TabIndex = 17;
            this.stepButton.Text = "Step";
            this.stepButton.Click += new System.EventHandler(this.stepButton_Click);
            // 
            // tabControl1
            // 
            this.tabControl1.Controls.Add(this.tabPage4);
            this.tabControl1.Controls.Add(this.tabPage6);
            this.tabControl1.Controls.Add(this.tabPage1);
            this.tabControl1.Controls.Add(this.tabPage2);
            this.tabControl1.Controls.Add(this.tabPage3);
            this.tabControl1.Controls.Add(this.tabPage5);
            this.tabControl1.Location = new System.Drawing.Point(8, 24);
            this.tabControl1.Name = "tabControl1";
            this.tabControl1.SelectedIndex = 0;
            this.tabControl1.Size = new System.Drawing.Size(408, 368);
            this.tabControl1.TabIndex = 18;
            // 
            // tabPage4
            // 
            this.tabPage4.Controls.Add(this.label10);
            this.tabPage4.Controls.Add(this.maxGenUpDown);
            this.tabPage4.Controls.Add(this.label3);
            this.tabPage4.Controls.Add(this.label2);
            this.tabPage4.Controls.Add(this.label1);
            this.tabPage4.Controls.Add(this.popSizeUpDown);
            this.tabPage4.Controls.Add(this.selRateUpDown);
            this.tabPage4.Controls.Add(this.muRateUpDown);
            this.tabPage4.Location = new System.Drawing.Point(4, 22);
            this.tabPage4.Name = "tabPage4";
            this.tabPage4.Size = new System.Drawing.Size(400, 342);
            this.tabPage4.TabIndex = 6;
            this.tabPage4.Text = "Settings";
            // 
            // label10
            // 
            this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label10.Location = new System.Drawing.Point(15, 15);
            this.label10.Name = "label10";
            this.label10.Size = new System.Drawing.Size(136, 16);
            this.label10.TabIndex = 28;
            this.label10.Text = "Maximum Generations:";
            this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // maxGenUpDown
            // 
            this.maxGenUpDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.maxGenUpDown.Location = new System.Drawing.Point(170, 13);
            this.maxGenUpDown.Maximum = new decimal(new int[] {
            50,
            0,
            0,
            0});
            this.maxGenUpDown.Minimum = new decimal(new int[] {
            2,
            0,
            0,
            0});
            this.maxGenUpDown.Name = "maxGenUpDown";
            this.maxGenUpDown.Size = new System.Drawing.Size(48, 21);
            this.maxGenUpDown.TabIndex = 27;
            this.maxGenUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.maxGenUpDown.Value = new decimal(new int[] {
            10,
            0,
            0,
            0});
            this.maxGenUpDown.ValueChanged += new System.EventHandler(this.maxGenUpDown_ValueChanged);
            // 
            // label3
            // 
            this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label3.Location = new System.Drawing.Point(15, 45);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(96, 16);
            this.label3.TabIndex = 26;
            this.label3.Text = "Population Size:";
            this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // label2
            // 
            this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.Location = new System.Drawing.Point(15, 75);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(96, 16);
            this.label2.TabIndex = 25;
            this.label2.Text = "Selection Rate:";
            this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // label1
            // 
            this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.Location = new System.Drawing.Point(15, 105);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(88, 16);
            this.label1.TabIndex = 24;
            this.label1.Text = "Mutation Rate:";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // popSizeUpDown
            // 
            this.popSizeUpDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.popSizeUpDown.Location = new System.Drawing.Point(170, 43);
            this.popSizeUpDown.Maximum = new decimal(new int[] {
            50,
            0,
            0,
            0});
            this.popSizeUpDown.Minimum = new decimal(new int[] {
            2,
            0,
            0,
            0});
            this.popSizeUpDown.Name = "popSizeUpDown";
            this.popSizeUpDown.Size = new System.Drawing.Size(48, 21);
            this.popSizeUpDown.TabIndex = 23;
            this.popSizeUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.popSizeUpDown.Value = new decimal(new int[] {
            5,
            0,
            0,
            0});
            this.popSizeUpDown.ValueChanged += new System.EventHandler(this.popSizeUpDown_ValueChanged);
            // 
            // selRateUpDown
            // 
            this.selRateUpDown.DecimalPlaces = 2;
            this.selRateUpDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.selRateUpDown.Increment = new decimal(new int[] {
            1,
            0,
            0,
            131072});
            this.selRateUpDown.Location = new System.Drawing.Point(170, 73);
            this.selRateUpDown.Maximum = new decimal(new int[] {
            5,
            0,
            0,
            65536});
            this.selRateUpDown.Name = "selRateUpDown";
            this.selRateUpDown.Size = new System.Drawing.Size(48, 21);
            this.selRateUpDown.TabIndex = 22;
            this.selRateUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.selRateUpDown.Value = new decimal(new int[] {
            4,
            0,
            0,
            65536});
            this.selRateUpDown.ValueChanged += new System.EventHandler(this.selRateUpDown_ValueChanged);
            // 
            // muRateUpDown
            // 
            this.muRateUpDown.DecimalPlaces = 2;
            this.muRateUpDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.muRateUpDown.Increment = new decimal(new int[] {
            1,
            0,
            0,
            131072});
            this.muRateUpDown.Location = new System.Drawing.Point(170, 103);
            this.muRateUpDown.Maximum = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.muRateUpDown.Name = "muRateUpDown";
            this.muRateUpDown.Size = new System.Drawing.Size(48, 21);
            this.muRateUpDown.TabIndex = 21;
            this.muRateUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.muRateUpDown.Value = new decimal(new int[] {
            1,
            0,
            0,
            131072});
            this.muRateUpDown.ValueChanged += new System.EventHandler(this.muRateUpDown_ValueChanged);
            // 
            // tabPage6
            // 
            this.tabPage6.Controls.Add(this.tabControl2);
            this.tabPage6.Location = new System.Drawing.Point(4, 22);
            this.tabPage6.Name = "tabPage6";
            this.tabPage6.Size = new System.Drawing.Size(400, 342);
            this.tabPage6.TabIndex = 5;
            this.tabPage6.Text = "Functions";
            // 
            // tabControl2
            // 
            this.tabControl2.Controls.Add(this.tabPage9);
            this.tabControl2.Controls.Add(this.tabPage8);
            this.tabControl2.Controls.Add(this.tabPage7);
            this.tabControl2.Location = new System.Drawing.Point(0, 0);
            this.tabControl2.Name = "tabControl2";
            this.tabControl2.SelectedIndex = 0;
            this.tabControl2.Size = new System.Drawing.Size(408, 344);
            this.tabControl2.TabIndex = 33;
            // 
            // tabPage9
            // 
            this.tabPage9.Controls.Add(this.label13);
            this.tabPage9.Controls.Add(this.label12);
            this.tabPage9.Controls.Add(this.label11);
            this.tabPage9.Controls.Add(this.polyCUpDown);
            this.tabPage9.Controls.Add(this.polyBUpDown);
            this.tabPage9.Controls.Add(this.polyAUpDown);
            this.tabPage9.Controls.Add(this.polynomialRadioButton);
            this.tabPage9.Controls.Add(this.xSquaredRadioButton);
            this.tabPage9.Controls.Add(this.xCubedRadioButton);
            this.tabPage9.Location = new System.Drawing.Point(4, 22);
            this.tabPage9.Name = "tabPage9";
            this.tabPage9.Size = new System.Drawing.Size(400, 318);
            this.tabPage9.TabIndex = 2;
            this.tabPage9.Text = "Polynomial";
            // 
            // label13
            // 
            this.label13.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label13.Location = new System.Drawing.Point(150, 61);
            this.label13.Name = "label13";
            this.label13.Size = new System.Drawing.Size(15, 12);
            this.label13.TabIndex = 32;
            this.label13.Text = "C:";
            // 
            // label12
            // 
            this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label12.Location = new System.Drawing.Point(150, 39);
            this.label12.Name = "label12";
            this.label12.Size = new System.Drawing.Size(15, 12);
            this.label12.TabIndex = 31;
            this.label12.Text = "B:";
            // 
            // label11
            // 
            this.label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label11.Location = new System.Drawing.Point(150, 16);
            this.label11.Name = "label11";
            this.label11.Size = new System.Drawing.Size(15, 12);
            this.label11.TabIndex = 30;
            this.label11.Text = "A:";
            // 
            // polyCUpDown
            // 
            this.polyCUpDown.DecimalPlaces = 1;
            this.polyCUpDown.Increment = new decimal(new int[] {
            5,
            0,
            0,
            65536});
            this.polyCUpDown.Location = new System.Drawing.Point(175, 57);
            this.polyCUpDown.Maximum = new decimal(new int[] {
            25,
            0,
            0,
            0});
            this.polyCUpDown.Minimum = new decimal(new int[] {
            25,
            0,
            0,
            -2147483648});
            this.polyCUpDown.Name = "polyCUpDown";
            this.polyCUpDown.Size = new System.Drawing.Size(60, 20);
            this.polyCUpDown.TabIndex = 29;
            this.polyCUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.polyCUpDown.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
            // 
            // polyBUpDown
            // 
            this.polyBUpDown.DecimalPlaces = 1;
            this.polyBUpDown.Increment = new decimal(new int[] {
            5,
            0,
            0,
            65536});
            this.polyBUpDown.Location = new System.Drawing.Point(175, 35);
            this.polyBUpDown.Maximum = new decimal(new int[] {
            25,
            0,
            0,
            0});
            this.polyBUpDown.Minimum = new decimal(new int[] {
            25,
            0,
            0,
            -2147483648});
            this.polyBUpDown.Name = "polyBUpDown";
            this.polyBUpDown.Size = new System.Drawing.Size(60, 20);
            this.polyBUpDown.TabIndex = 28;
            this.polyBUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.polyBUpDown.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
            // 
            // polyAUpDown
            // 
            this.polyAUpDown.DecimalPlaces = 1;
            this.polyAUpDown.Increment = new decimal(new int[] {
            5,
            0,
            0,
            65536});
            this.polyAUpDown.Location = new System.Drawing.Point(175, 12);
            this.polyAUpDown.Maximum = new decimal(new int[] {
            25,
            0,
            0,
            0});
            this.polyAUpDown.Minimum = new decimal(new int[] {
            25,
            0,
            0,
            -2147483648});
            this.polyAUpDown.Name = "polyAUpDown";
            this.polyAUpDown.Size = new System.Drawing.Size(60, 20);
            this.polyAUpDown.TabIndex = 27;
            this.polyAUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.polyAUpDown.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
            // 
            // polynomialRadioButton
            // 
            this.polynomialRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.polynomialRadioButton.Location = new System.Drawing.Point(15, 15);
            this.polynomialRadioButton.Name = "polynomialRadioButton";
            this.polynomialRadioButton.Size = new System.Drawing.Size(113, 17);
            this.polynomialRadioButton.TabIndex = 26;
            this.polynomialRadioButton.Text = "A x^2 + B x + C";
            this.polynomialRadioButton.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
            this.polynomialRadioButton.CheckedChanged += new System.EventHandler(this.polynomialRadioButton_CheckedChanged);
            // 
            // xSquaredRadioButton
            // 
            this.xSquaredRadioButton.Checked = true;
            this.xSquaredRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.xSquaredRadioButton.Location = new System.Drawing.Point(15, 96);
            this.xSquaredRadioButton.Name = "xSquaredRadioButton";
            this.xSquaredRadioButton.Size = new System.Drawing.Size(48, 16);
            this.xSquaredRadioButton.TabIndex = 24;
            this.xSquaredRadioButton.TabStop = true;
            this.xSquaredRadioButton.Text = "x^2";
            this.xSquaredRadioButton.CheckedChanged += new System.EventHandler(this.xSquaredRadioButton_CheckedChanged);
            // 
            // xCubedRadioButton
            // 
            this.xCubedRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.xCubedRadioButton.Location = new System.Drawing.Point(15, 128);
            this.xCubedRadioButton.Name = "xCubedRadioButton";
            this.xCubedRadioButton.Size = new System.Drawing.Size(48, 16);
            this.xCubedRadioButton.TabIndex = 25;
            this.xCubedRadioButton.Text = "x^3";
            this.xCubedRadioButton.CheckedChanged += new System.EventHandler(this.xCubedRadioButton_CheckedChanged);
            // 
            // tabPage8
            // 
            this.tabPage8.Controls.Add(this.sigmoidRadioButton);
            this.tabPage8.Controls.Add(this.logisticRadioButton);
            this.tabPage8.Controls.Add(this.oneOverXRadioButton);
            this.tabPage8.Controls.Add(this.oneOverOneMinusXRadioButton);
            this.tabPage8.Location = new System.Drawing.Point(4, 22);
            this.tabPage8.Name = "tabPage8";
            this.tabPage8.Size = new System.Drawing.Size(400, 318);
            this.tabPage8.TabIndex = 1;
            this.tabPage8.Text = "Rational";
            // 
            // sigmoidRadioButton
            // 
            this.sigmoidRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.sigmoidRadioButton.Location = new System.Drawing.Point(15, 105);
            this.sigmoidRadioButton.Name = "sigmoidRadioButton";
            this.sigmoidRadioButton.Size = new System.Drawing.Size(88, 20);
            this.sigmoidRadioButton.TabIndex = 20;
            this.sigmoidRadioButton.Text = "1 / (1+e^x)";
            this.sigmoidRadioButton.CheckedChanged += new System.EventHandler(this.sigmoidRadioButton_CheckedChanged);
            // 
            // logisticRadioButton
            // 
            this.logisticRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.logisticRadioButton.Location = new System.Drawing.Point(15, 75);
            this.logisticRadioButton.Name = "logisticRadioButton";
            this.logisticRadioButton.Size = new System.Drawing.Size(64, 20);
            this.logisticRadioButton.TabIndex = 19;
            this.logisticRadioButton.Text = "x / (1-x)";
            this.logisticRadioButton.CheckedChanged += new System.EventHandler(this.logisticRadioButton_CheckedChanged);
            // 
            // oneOverXRadioButton
            // 
            this.oneOverXRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.oneOverXRadioButton.Location = new System.Drawing.Point(15, 45);
            this.oneOverXRadioButton.Name = "oneOverXRadioButton";
            this.oneOverXRadioButton.Size = new System.Drawing.Size(60, 20);
            this.oneOverXRadioButton.TabIndex = 18;
            this.oneOverXRadioButton.Text = "1 / x";
            this.oneOverXRadioButton.CheckedChanged += new System.EventHandler(this.oneOverXRadioButton_CheckedChanged);
            // 
            // oneOverOneMinusXRadioButton
            // 
            this.oneOverOneMinusXRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.oneOverOneMinusXRadioButton.Location = new System.Drawing.Point(15, 15);
            this.oneOverOneMinusXRadioButton.Name = "oneOverOneMinusXRadioButton";
            this.oneOverOneMinusXRadioButton.Size = new System.Drawing.Size(72, 20);
            this.oneOverOneMinusXRadioButton.TabIndex = 17;
            this.oneOverOneMinusXRadioButton.Text = "1 / (1-x)";
            this.oneOverOneMinusXRadioButton.CheckedChanged += new System.EventHandler(this.oneOverOneMinusXRadioButton_CheckedChanged);
            // 
            // tabPage7
            // 
            this.tabPage7.Controls.Add(this.xSineRadioButton);
            this.tabPage7.Controls.Add(this.sineExpRadioButton);
            this.tabPage7.Controls.Add(this.absSineRadioButton);
            this.tabPage7.Controls.Add(this.SineRadioButton);
            this.tabPage7.Controls.Add(this.expSineRadioButton);
            this.tabPage7.Controls.Add(this.label9);
            this.tabPage7.Controls.Add(this.periodUpDown);
            this.tabPage7.Location = new System.Drawing.Point(4, 22);
            this.tabPage7.Name = "tabPage7";
            this.tabPage7.Size = new System.Drawing.Size(400, 318);
            this.tabPage7.TabIndex = 0;
            this.tabPage7.Text = "Trig";
            // 
            // xSineRadioButton
            // 
            this.xSineRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.xSineRadioButton.Location = new System.Drawing.Point(15, 135);
            this.xSineRadioButton.Name = "xSineRadioButton";
            this.xSineRadioButton.Size = new System.Drawing.Size(64, 20);
            this.xSineRadioButton.TabIndex = 24;
            this.xSineRadioButton.Text = "x Sin(x)";
            this.xSineRadioButton.CheckedChanged += new System.EventHandler(this.xSineRadioButton_CheckedChanged);
            // 
            // sineExpRadioButton
            // 
            this.sineExpRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.sineExpRadioButton.Location = new System.Drawing.Point(15, 45);
            this.sineExpRadioButton.Name = "sineExpRadioButton";
            this.sineExpRadioButton.Size = new System.Drawing.Size(70, 20);
            this.sineExpRadioButton.TabIndex = 21;
            this.sineExpRadioButton.Text = "Sin(e^x)";
            this.sineExpRadioButton.CheckedChanged += new System.EventHandler(this.sineExpRadioButton_CheckedChanged);
            // 
            // absSineRadioButton
            // 
            this.absSineRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.absSineRadioButton.Location = new System.Drawing.Point(15, 105);
            this.absSineRadioButton.Name = "absSineRadioButton";
            this.absSineRadioButton.Size = new System.Drawing.Size(70, 20);
            this.absSineRadioButton.TabIndex = 19;
            this.absSineRadioButton.Text = "| Sin(x) |";
            this.absSineRadioButton.CheckedChanged += new System.EventHandler(this.absSineRadioButton_CheckedChanged);
            // 
            // SineRadioButton
            // 
            this.SineRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.SineRadioButton.Location = new System.Drawing.Point(15, 15);
            this.SineRadioButton.Name = "SineRadioButton";
            this.SineRadioButton.Size = new System.Drawing.Size(60, 20);
            this.SineRadioButton.TabIndex = 16;
            this.SineRadioButton.Text = "Sin (x)";
            this.SineRadioButton.CheckedChanged += new System.EventHandler(this.SineRadioButton_CheckedChanged);
            // 
            // expSineRadioButton
            // 
            this.expSineRadioButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.expSineRadioButton.Location = new System.Drawing.Point(15, 75);
            this.expSineRadioButton.Name = "expSineRadioButton";
            this.expSineRadioButton.Size = new System.Drawing.Size(75, 20);
            this.expSineRadioButton.TabIndex = 20;
            this.expSineRadioButton.Text = "e ^ Sin(x)";
            this.expSineRadioButton.CheckedChanged += new System.EventHandler(this.expSineRadioButton_CheckedChanged);
            // 
            // label9
            // 
            this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label9.Location = new System.Drawing.Point(175, 17);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(48, 16);
            this.label9.TabIndex = 23;
            this.label9.Text = "Period:";
            this.label9.TextAlign = System.Drawing.ContentAlignment.BottomRight;
            // 
            // periodUpDown
            // 
            this.periodUpDown.Increment = new decimal(new int[] {
            8,
            0,
            0,
            0});
            this.periodUpDown.Location = new System.Drawing.Point(240, 15);
            this.periodUpDown.Maximum = new decimal(new int[] {
            512,
            0,
            0,
            0});
            this.periodUpDown.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.periodUpDown.Name = "periodUpDown";
            this.periodUpDown.Size = new System.Drawing.Size(48, 20);
            this.periodUpDown.TabIndex = 22;
            this.periodUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.periodUpDown.Value = new decimal(new int[] {
            64,
            0,
            0,
            0});
            // 
            // tabPage1
            // 
            this.tabPage1.Controls.Add(this.output1TextBox);
            this.tabPage1.Location = new System.Drawing.Point(4, 22);
            this.tabPage1.Name = "tabPage1";
            this.tabPage1.Size = new System.Drawing.Size(400, 342);
            this.tabPage1.TabIndex = 0;
            this.tabPage1.Text = "Output1";
            // 
            // tabPage2
            // 
            this.tabPage2.Controls.Add(this.output2TextBox);
            this.tabPage2.Location = new System.Drawing.Point(4, 22);
            this.tabPage2.Name = "tabPage2";
            this.tabPage2.Size = new System.Drawing.Size(400, 342);
            this.tabPage2.TabIndex = 1;
            this.tabPage2.Text = "Output2";
            // 
            // output2TextBox
            // 
            this.output2TextBox.Location = new System.Drawing.Point(8, 7);
            this.output2TextBox.Name = "output2TextBox";
            this.output2TextBox.Size = new System.Drawing.Size(384, 330);
            this.output2TextBox.TabIndex = 13;
            this.output2TextBox.Text = "";
            // 
            // tabPage3
            // 
            this.tabPage3.Controls.Add(this.textBox7);
            this.tabPage3.Controls.Add(this.textBox8);
            this.tabPage3.Controls.Add(this.textBox9);
            this.tabPage3.Controls.Add(this.textBox10);
            this.tabPage3.Controls.Add(this.textBox11);
            this.tabPage3.Controls.Add(this.textBox12);
            this.tabPage3.Controls.Add(this.textBox4);
            this.tabPage3.Controls.Add(this.textBox5);
            this.tabPage3.Controls.Add(this.textBox6);
            this.tabPage3.Controls.Add(this.textBox2);
            this.tabPage3.Controls.Add(this.textBox3);
            this.tabPage3.Controls.Add(this.textBox1);
            this.tabPage3.Location = new System.Drawing.Point(4, 22);
            this.tabPage3.Name = "tabPage3";
            this.tabPage3.Size = new System.Drawing.Size(400, 342);
            this.tabPage3.TabIndex = 2;
            this.tabPage3.Text = "Statistics";
            // 
            // textBox7
            // 
            this.textBox7.Location = new System.Drawing.Point(224, 200);
            this.textBox7.Name = "textBox7";
            this.textBox7.Size = new System.Drawing.Size(56, 20);
            this.textBox7.TabIndex = 12;
            // 
            // textBox8
            // 
            this.textBox8.Location = new System.Drawing.Point(224, 232);
            this.textBox8.Name = "textBox8";
            this.textBox8.Size = new System.Drawing.Size(56, 20);
            this.textBox8.TabIndex = 13;
            // 
            // textBox9
            // 
            this.textBox9.Location = new System.Drawing.Point(224, 168);
            this.textBox9.Name = "textBox9";
            this.textBox9.Size = new System.Drawing.Size(56, 20);
            this.textBox9.TabIndex = 11;
            // 
            // textBox10
            // 
            this.textBox10.Location = new System.Drawing.Point(80, 200);
            this.textBox10.Name = "textBox10";
            this.textBox10.Size = new System.Drawing.Size(56, 20);
            this.textBox10.TabIndex = 9;
            // 
            // textBox11
            // 
            this.textBox11.Location = new System.Drawing.Point(80, 232);
            this.textBox11.Name = "textBox11";
            this.textBox11.Size = new System.Drawing.Size(56, 20);
            this.textBox11.TabIndex = 10;
            // 
            // textBox12
            // 
            this.textBox12.Location = new System.Drawing.Point(80, 168);
            this.textBox12.Name = "textBox12";
            this.textBox12.Size = new System.Drawing.Size(56, 20);
            this.textBox12.TabIndex = 8;
            // 
            // textBox4
            // 
            this.textBox4.Location = new System.Drawing.Point(224, 64);
            this.textBox4.Name = "textBox4";
            this.textBox4.Size = new System.Drawing.Size(56, 20);
            this.textBox4.TabIndex = 6;
            // 
            // textBox5
            // 
            this.textBox5.Location = new System.Drawing.Point(224, 96);
            this.textBox5.Name = "textBox5";
            this.textBox5.Size = new System.Drawing.Size(56, 20);
            this.textBox5.TabIndex = 7;
            // 
            // textBox6
            // 
            this.textBox6.Location = new System.Drawing.Point(224, 32);
            this.textBox6.Name = "textBox6";
            this.textBox6.Size = new System.Drawing.Size(56, 20);
            this.textBox6.TabIndex = 5;
            // 
            // tabPage5
            // 
            this.tabPage5.Controls.Add(this.label4);
            this.tabPage5.Controls.Add(this.functionResUpDown);
            this.tabPage5.Location = new System.Drawing.Point(4, 22);
            this.tabPage5.Name = "tabPage5";
            this.tabPage5.Size = new System.Drawing.Size(400, 342);
            this.tabPage5.TabIndex = 4;
            this.tabPage5.Text = "Plot Options";
            // 
            // label4
            // 
            this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label4.Location = new System.Drawing.Point(15, 15);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(72, 16);
            this.label4.TabIndex = 22;
            this.label4.Text = "Resolution:";
            this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // functionResUpDown
            // 
            this.functionResUpDown.Increment = new decimal(new int[] {
            10,
            0,
            0,
            0});
            this.functionResUpDown.Location = new System.Drawing.Point(95, 14);
            this.functionResUpDown.Maximum = new decimal(new int[] {
            500,
            0,
            0,
            0});
            this.functionResUpDown.Minimum = new decimal(new int[] {
            10,
            0,
            0,
            0});
            this.functionResUpDown.Name = "functionResUpDown";
            this.functionResUpDown.Size = new System.Drawing.Size(48, 20);
            this.functionResUpDown.TabIndex = 21;
            this.functionResUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.functionResUpDown.Value = new decimal(new int[] {
            200,
            0,
            0,
            0});
            this.functionResUpDown.ValueChanged += new System.EventHandler(this.functionResUpDown_ValueChanged);
            // 
            // evolveButton
            // 
            this.evolveButton.Location = new System.Drawing.Point(616, 16);
            this.evolveButton.Name = "evolveButton";
            this.evolveButton.Size = new System.Drawing.Size(64, 24);
            this.evolveButton.TabIndex = 21;
            this.evolveButton.Text = "Evolve";
            this.evolveButton.Click += new System.EventHandler(this.evolveButton_Click);
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(504, 48);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(64, 24);
            this.button1.TabIndex = 22;
            this.button1.Text = "Stop";
            this.button1.Click += new System.EventHandler(this.stopButton_Click);
            // 
            // tabControl3
            // 
            this.tabControl3.Controls.Add(this.tabPage10);
            this.tabControl3.Controls.Add(this.tabPage11);
            this.tabControl3.Controls.Add(this.tabPage12);
            this.tabControl3.Location = new System.Drawing.Point(436, 96);
            this.tabControl3.Name = "tabControl3";
            this.tabControl3.SelectedIndex = 0;
            this.tabControl3.Size = new System.Drawing.Size(280, 296);
            this.tabControl3.TabIndex = 23;
            // 
            // tabPage10
            // 
            this.tabPage10.Controls.Add(this.panel1);
            this.tabPage10.Location = new System.Drawing.Point(4, 22);
            this.tabPage10.Name = "tabPage10";
            this.tabPage10.Size = new System.Drawing.Size(272, 270);
            this.tabPage10.TabIndex = 0;
            this.tabPage10.Text = "2D Plot";
            // 
            // panel1
            // 
            this.panel1.BackColor = System.Drawing.Color.LightGray;
            this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.panel1.Location = new System.Drawing.Point(8, 8);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(255, 255);
            this.panel1.TabIndex = 1;

            // 
            // tabPage11
            // 
            this.tabPage11.Controls.Add(this.panel2);
            this.tabPage11.Location = new System.Drawing.Point(4, 22);
            this.tabPage11.Name = "tabPage11";
            this.tabPage11.Size = new System.Drawing.Size(272, 270);
            this.tabPage11.TabIndex = 1;
            this.tabPage11.Text = "3D Plot";
            // 
            // panel2
            // 
            this.panel2.BackColor = System.Drawing.Color.LightGray;
            this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.panel2.Location = new System.Drawing.Point(8, 8);
            this.panel2.Name = "panel2";
            this.panel2.Size = new System.Drawing.Size(255, 255);
            this.panel2.TabIndex = 1;
            // 
            // tabPage12
            // 
            this.tabPage12.Controls.Add(this.panel3);
            this.tabPage12.Location = new System.Drawing.Point(4, 22);
            this.tabPage12.Name = "tabPage12";
            this.tabPage12.Size = new System.Drawing.Size(272, 270);
            this.tabPage12.TabIndex = 2;
            this.tabPage12.Text = "Contour";
            // 
            // panel3
            // 
            this.panel3.BackColor = System.Drawing.Color.LightGray;
            this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.panel3.Location = new System.Drawing.Point(8, 8);
            this.panel3.Name = "panel3";
            this.panel3.Size = new System.Drawing.Size(255, 255);
            this.panel3.TabIndex = 1;
            // 
            // GATool
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(728, 406);
            this.Controls.Add(this.tabControl3);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.evolveButton);
            this.Controls.Add(this.tabControl1);
            this.Controls.Add(this.stepButton);
            this.Controls.Add(this.quitButton);
            this.Controls.Add(this.startButton);
            this.Name = "GATool";
            this.Text = "GATool";
            this.Load += new System.EventHandler(this.GATool_Load);
            this.tabControl1.ResumeLayout(false);
            this.tabPage4.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.maxGenUpDown)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.popSizeUpDown)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.selRateUpDown)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.muRateUpDown)).EndInit();
            this.tabPage6.ResumeLayout(false);
            this.tabControl2.ResumeLayout(false);
            this.tabPage9.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.polyCUpDown)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.polyBUpDown)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.polyAUpDown)).EndInit();
            this.tabPage8.ResumeLayout(false);
            this.tabPage7.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.periodUpDown)).EndInit();
            this.tabPage1.ResumeLayout(false);
            this.tabPage2.ResumeLayout(false);
            this.tabPage3.ResumeLayout(false);
            this.tabPage3.PerformLayout();
            this.tabPage5.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.functionResUpDown)).EndInit();
            this.tabControl3.ResumeLayout(false);
            this.tabPage10.ResumeLayout(false);
            this.tabPage11.ResumeLayout(false);
            this.tabPage12.ResumeLayout(false);
            this.ResumeLayout(false);

		}
		#endregion

		#region Member Declerations
		
		private GA ga;
    	private AFunction aFunc;

		private int functionResolution;
		private float muRate;
		private float selRate;
		private int popSize;
		private int genCount = 0;

        //private GraphicsState panel1State;
        //private GraphicsState panel2State;
        private Graphics graphicPanel;
		private Graphics graphicPanel2;

		#endregion


		#region Event Handlers

		private void polynomialRadioButton_CheckedChanged(object sender, System.EventArgs e)
		{
			aFunc = new AFunction(TwoDFunctions.Polynomial);
		}

		private void xSquaredRadioButton_CheckedChanged(object sender, System.EventArgs e)
		{
			aFunc = new AFunction(TwoDFunctions.XSquared);
		}

		private void xCubedRadioButton_CheckedChanged(object sender, System.EventArgs e)
		{
			aFunc = new AFunction(TwoDFunctions.XCubed);
		}

		private void SineRadioButton_CheckedChanged(object sender, System.EventArgs e)
		{
			aFunc = new AFunction(TwoDFunctions.Sine);
		}

		private void oneOverOneMinusXRadioButton_CheckedChanged(object sender, System.EventArgs e)
		{
			aFunc = new AFunction(TwoDFunctions.OneOverOneMinusX);
		}

		private void oneOverXRadioButton_CheckedChanged(object sender, System.EventArgs e)
		{
			aFunc = new AFunction(TwoDFunctions.OneOverX);
		}

		private void logisticRadioButton_CheckedChanged(object sender, System.EventArgs e)
		{
			aFunc = new AFunction(TwoDFunctions.Logistic);
		}

		private void sigmoidRadioButton_CheckedChanged(object sender, System.EventArgs e)
		{
			aFunc = new AFunction(TwoDFunctions.Sigmoid);
		}

		private void sineExpRadioButton_CheckedChanged(object sender, System.EventArgs e)
		{
			aFunc = new AFunction(TwoDFunctions.SineExp);
		}

		private void expSineRadioButton_CheckedChanged(object sender, System.EventArgs e)
		{
			aFunc = new AFunction(TwoDFunctions.ExpSine);
		}

		private void absSineRadioButton_CheckedChanged(object sender, System.EventArgs e)
		{
			aFunc = new AFunction(TwoDFunctions.AbsSine);
		}

		private void xSineRadioButton_CheckedChanged(object sender, System.EventArgs e)
		{
			aFunc = new AFunction(TwoDFunctions.XSine);
		}

		private void maxGenUpDown_ValueChanged(object sender, System.EventArgs e)
		{
			genCount = (int) maxGenUpDown.Value;
		}

		private void muRateUpDown_ValueChanged(object sender, System.EventArgs e)
		{
			muRate = (float) muRateUpDown.Value;
		}

		private void selRateUpDown_ValueChanged(object sender, System.EventArgs e)
		{
			selRate = (float) selRateUpDown.Value;
		}

		private void popSizeUpDown_ValueChanged(object sender, System.EventArgs e)
		{
			popSize = (int) popSizeUpDown.Value;
		}

		private void functionResUpDown_ValueChanged(object sender, System.EventArgs e)
		{
			functionResolution = (int) functionResUpDown.Value;
		}
		
		private void quitButton_Click(object sender, System.EventArgs e)
		{
			Close();
		}

		private void stopButton_Click(object sender, System.EventArgs e)
		{
			panel1.Refresh();
			//drawContour();
            //draw3D();
		}

		
		private void GATool_Load(object sender, System.EventArgs e)
		{
			aFunc = new AFunction(TwoDFunctions.XSquared);
			graphicPanel = panel1.CreateGraphics();
			graphicPanel2 = panel2.CreateGraphics();

			//panel1State = graphicPanel.Save();
			
			muRate = (float) muRateUpDown.Value;
			selRate = (float) selRateUpDown.Value;
			popSize = (int) popSizeUpDown.Value;

			functionResolution = (int) functionResUpDown.Value;
		}
		
		private void startButton_Click(object sender, System.EventArgs e)
		{
            //panel1.Refresh();

            //TwoDFunctions.Period = (int)periodUpDown.Value;

            //double [] constants = new double[3];
            //constants[0] = (double) polyAUpDown.Value;
            //constants[1] = (double) polyBUpDown.Value;
            //constants[2] = (double) polyCUpDown.Value;

            //TwoDFunctions.PolyConstants = constants;

            //DrawFunction(Color.Black, aFunc, functionResolution);

            //ga = new GA();
            //ga.FitnessFunction = new FitFunc(aFunc);
            //ga.Initiate(popSize, muRate, selRate);

            //output1TextBox.Text = ga.ToString();
            //DrawData();

            //panel1State = graphicPanel.Save();
		}

		private float function3D(float x, float y)
		{
			//float xMax = 128*128;
			//float yMax = 128*128;
			//float z = x*x/xMax - y*y/yMax;
			float z = (float)Math.Cos(x) + (float)Math.Sin(y);
			//float z = (float) Math.Cos(x*x + y*y);
			//float z = (float) Math.Sin( Math.Abs(x) - Math.Abs(y) );
			return z;
		
		}

   

        private void drawContour()
		{
			Bitmap contourBitmap = new Bitmap(256, 256);

			int w = contourBitmap.Width;
			int h = contourBitmap.Height;

			int temp;
			for(int i = 0; i < w; i += 5)
				for(int j = 0; j < h; j += 5)
				{
					
					int x = i - (int) w/2;
					int y = j - (int) h/2;	

					float z = function3D(x, y);

					if(z < -1.0)
						contourBitmap.SetPixel(i, j, Color.Black);
					else if (z < -0.5)
						contourBitmap.SetPixel(i, j, Color.Blue);
					else if (z < 0.0)
						contourBitmap.SetPixel(i, j, Color.Red);
					else if (z < 0.5)
						contourBitmap.SetPixel(i, j, Color.Green);
					else
						contourBitmap.SetPixel(i, j, Color.Yellow);

					if(i == 25)
						temp = j;
				}
			
			Color c = contourBitmap.GetPixel(25, 0);
			graphicPanel.DrawImage(contourBitmap, 0, 0, 255, 255);	
		}
 

		private void stepButton_Click(object sender, System.EventArgs e)
		{
			panel1.Refresh();
		
			DrawFunction(Color.Black, aFunc, functionResolution);

			ga.DoStep(popSize, muRate, selRate);

			output1TextBox.Text += "\n" + ga.ToString();
			output1TextBox.Focus();
			output1TextBox.SelectionStart = output1TextBox.Text.Length;
			output1TextBox.ScrollToCaret();

			DrawData();
		}
		
		private void evolveButton_Click(object sender, System.EventArgs e)
		{
			panel1.Refresh();

			TwoDFunctions.Period = (int)periodUpDown.Value;
			
			double [] constants = new double[3];
			constants[0] = (double) polyAUpDown.Value;
			constants[1] = (double) polyBUpDown.Value;
			constants[2] = (double) polyCUpDown.Value;

			TwoDFunctions.PolyConstants = constants;

			DrawFunction(Color.Black, aFunc, functionResolution);

			ga = new GA();
			ga.FitnessFunction = new FitFunc(aFunc);
			ga.Initiate(popSize);
			
			output1TextBox.Text = ga.ToString();
			DrawData();

			for(int i = 0; i < genCount; i++)
			{
				panel1.Refresh();
				//DrawAxis(Color.DarkGray);
				DrawFunction(Color.Black, aFunc, functionResolution);

				ga.DoStep(popSize, muRate, selRate);

				output1TextBox.Text += "\n" + ga.ToString();
				output1TextBox.Focus();
				output1TextBox.SelectionStart = output1TextBox.Text.Length;
				output1TextBox.ScrollToCaret();

				DrawData();
			}
		}


		#endregion

		#region Drawing Stuff

		private void DrawData(Color color, PointF [] points)
		{
		
		}

		private void DrawData()
		{
            
            //Population pop = ga.GetPopulation();
			
            //Genome1A chrom;
            //for (int i = 1; i < popSize-1; i++)
            //{
            //    chrom = pop.GetGenome(i);
            //    //DrawDataPoint(Color.Red, chrom.IntValue, chrom.FitnessValue);
            //}
			
            //// draw worse
            //chrom = pop.GetGenome(popSize-1);
            //DrawDataPoint(Color.Yellow, chrom.IntValue, chrom.FitnessValue);

            //// draw best
            //chrom = pop.GetGenome(0);
            //DrawDataPoint(Color.Blue, chrom.IntValue, chrom.FitnessValue);

		}
		
		private void DrawFunction(Color color, AFunction aFunction, int resolution)
		{
            //PointF[] points;
            //points = new PointF[resolution];

            //int w = panel1.Width;
            //int h = panel1.Height;

            //for(int i = 0; i < resolution; i ++)
            //{
            //    // lerp
            //    double t = (1 - ((double)i/resolution))*(-w/2) + ((double)i/resolution)*(w/2);
            //    double [] val = new double [1];
            //    val[0] = t;
            //    points[i] = new Point((int) t, (int) aFunction(val));
            //}

            //this.DrawLines(color, points);
		}


		private void DrawLines(Color color, PointF [] points)
		{
            //Pen myPen = new Pen(color, (float)0.5);
		
            //int w = panel1.Width;
            //int h = panel1.Height;

            //for(int i = 0; i < points.Length-1; i++)
            //    graphicPanel.DrawLine(myPen, points[i].X + w/2, h/2 - points[i].Y,
            //        points[i+1].X + w/2, h/2 - points[i+1].Y);

		}
        //private void DrawDataPoint(Color color, double x, double y)
        //{
        //    Pen myPen = new Pen(color, (float)0.5);
			
        //    int w = panel1.Width;
        //    int h = panel1.Height;

        //    graphicPanel.DrawEllipse(myPen, (float)(x+w/2-3.0), (float)(h/2-y-3.0), 6.0f, 6.0f);
        //}

	
        //private void DrawAxis(Color color)
        //{
        //    Pen myPen = new Pen(color, (float)0.5);
			
        //    int w = panel1.Width;
        //    int h = panel1.Height;

        //    // draw axis
        //    graphicPanel.DrawLine(myPen, new Point(w/2, 0),
        //        new Point(w/2, h));									

        //    graphicPanel.DrawLine(myPen, new Point(0, h/2),
        //        new Point(w, h/2));									
        //}

//        private void draw3D()
//        {
////			int[,] grid = new int[255, 255];
//
//			Pen myPen = new Pen(Color.Red, (float)0.5);
//			
//			for(int i = 0; i < 255; i++)
//			{
//				for(int j = 0; j < 255; j++)
//				{
//					grid[i, j] = i*i + j;
//
//					if( i*i + j == -20)
//						myPen = new Pen(Color.Blue, (float)0.5);
//					else if( i*i + j == 0)
//						myPen = new Pen(Color.Green, (float)0.5);
//					else if( i*i + j == 20)
//						myPen = new Pen(Color.Orange, (float)0.5);
//
//					graphicPanel2.DrawEllipse(myPen, i, j, 2, 2);
//				
//				}
//			}
        //}

		
		#endregion



	}
}
